from rest_framework import serializers
import json, datetime, logging, requests, math
from encourage.filters_encourage import *
from encourage.models import *


#商户达标奖-客管推送记录
class EncourageKeGuanListModelSerializer(serializers.ModelSerializer):
    push_status_str = serializers.CharField(source='get_push_status_display', read_only=True)
    push_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S", required=False)
    payment_no = serializers.SerializerMethodField(read_only=True)

    class Meta:
        model = EncourageDrawDataKeguan
        fields = ['id', 'push_status_str', 'push_status', 'push_time', 'return_msg', 'encouragedraw_id',
                  'payment_no']

    def get_payment_no(self, obj):
        try:
            return obj.encouragedraw.payment_no
        except:
            return ''
